package com.hanfeng.weibo.client;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
/**
 * 
 * @author hanfeng
 * @data 2012-9-3 下午2:30:26
 */
public class SplashActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        	// 取消标题栏
     		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
     		// 设置全屏
     		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
     				WindowManager.LayoutParams.FLAG_FULLSCREEN);
     		//设置Activity布局
            setContentView(R.layout.activity_splash);
     		//实例化ImageView
     		ImageView ivSplash  = (ImageView)findViewById(R.id.logo);
     		//实例动画对象
     		Animation animation = AnimationUtils.loadAnimation(this, R.anim.splash);
     		//启动动画
     		ivSplash.startAnimation(animation);
     		//设置动画显示时间，单位毫秒
     		animation.setDuration(3000);
     		//设置动画监听器
     		animation.setAnimationListener(new AnimationListener() {
     			
     			@Override
     			public void onAnimationStart(Animation animation) {
     				// TODO Auto-generated method stub
     				
     			}
     			
     			@Override
     			public void onAnimationRepeat(Animation animation) {
     				// TODO Auto-generated method stub
     				
     			}
     			
     			@Override
     			public void onAnimationEnd(Animation animation) {
     				//动画结束时候跳转到播放器主界面
     				Intent intent = new Intent(SplashActivity.this,LoginActivity.class);
     				startActivity(intent);
     				//结束动画Activity
     				SplashActivity.this.finish();				
     			}
     		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_splash, menu);
        return true;
    }
}
